package com.hziee.graduate.ticket.controller;


import com.hziee.graduate.ticket.dto.R;
import com.hziee.graduate.ticket.entity.Region;
import com.hziee.graduate.ticket.service.RegionService;
import com.hziee.graduate.ticket.vo.AreaVO;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;


@RestController
@RequestMapping("region")
public class RegionController {

    @Resource
    private RegionService regionService;

    /*
     * @description: 获得第几级的地区列表 类似广度优先搜索
     * @author: huwanxiao
     * @date: 2022/9/7 9:35
     **/
    @GetMapping("getRegionVOByLevel/{level}")
    public R<List<Region>> getRegionVOByLevel(@PathVariable Integer level) {
        return regionService.getRegionVOByLevel(level);
    }

    /*
     * @description: 根据父级id获得子地区列表 类似深度优先搜索
     * @author: huwanxiao
     * @date: 2022/9/7 9:40
     **/
    @GetMapping("loadRegionVOByPid/{pid}")
    public R<List<Region>> loadRegionVOByPid(@PathVariable Integer pid) {
        return regionService.loadRegionVOByPid(pid);
    }

    @GetMapping("getAreaByCity/{locationName}")
    public R<List<AreaVO>> getAreaByCity(@PathVariable String locationName) {
        return regionService.getAreaByCity(locationName);
    }
}

